home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / listings / v_09_04 / 9n04088a < prev    next >
Text File  |  1991-02-13  |  936b  |  52 lines

  1.  
  2. /* all_true.c */
  3. /* ---------- */
  4. /*
  5.      No matter what code the calling program returns, this 
  6.      program will always return 0 (success).
  7.  
  8.      Usage:  all_true program args
  9.      Example: all_true sleep 5
  10.  
  11. */
  12.  
  13.  
  14. #include <stdio.h>
  15. #include <signal.h>
  16.  
  17. #define RET_VALUE        0
  18.  
  19. main(argc,argv)
  20. int argc;
  21. char **argv;
  22.      {
  23.      process(argc,argv);
  24.      exit(RET_VALUE);
  25.      }
  26.  
  27. process(argc,argv)
  28. int argc;
  29. char **argv;
  30.      {
  31.      int pid;
  32.  
  33.      if ((pid = fork()) == -1)
  34.       {
  35.           perror("all_true");
  36.           exit(1);
  37.       }
  38.  
  39.      if (pid > 0 )
  40.       {
  41.       signal(SIGINT,SIG_IGN); /* Ignore interrupt key */
  42.           while (wait( (int *) 0 ) == pid);
  43.           return;
  44.       }
  45.      
  46.      signal(SIGINT,SIG_DFL);  /* Default interrupt key */
  47.      argv++;                  /* Point to program argument */
  48.      execvp(*argv, argv);
  49.      perror("all_true");
  50.      }
  51.  
  52.